﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Collections;


namespace Lola.Persistencia
{
    public class AdministradorPersistenciaChofer
    {
        private static AdministradorPersistenciaChofer admCh;

        public static AdministradorPersistenciaChofer getInstanciaChofer()
        {
            if(admCh==null)
                admCh=new AdministradorPersistenciaChofer();
            return admCh;
        }

        public Chofer buscarChofer(int legajo)
        {
           using (SEMINARIOIEntities contextSeminarioI = new SEMINARIOIEntities())
           {
            var query = from p in contextSeminarioI.Chofer
                        where p.legajo==legajo 
                        select p;
            Chofer ch = query.First();       
            return ch;
           }
        }

        public List<Chofer> buscarChoferes()
        {
            List<Chofer> result = new List<Chofer>();

            using (SEMINARIOIEntities contextSeminarioI = new SEMINARIOIEntities())
            {
                IEnumerable<Chofer> chs= from p in contextSeminarioI.Chofer
                            select p;

                foreach (Chofer ch in chs)
                {
                    result.Add(ch);
                }
            }
            return result;
        }
        

    }
}
